package day_2022_1_to_2.day16;

//2、将一个字符串从左开始前k个字符进行旋转：左旋数组 。例如字符串："abcdef"，前2个左旋结果是："cdefab"。

import java.util.Scanner;

public class Day7_2 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String str="abcdef";
        System.out.println("请输入从左开始要进行左旋字符的个数：");
        int n=scanner.nextInt();
        LeftRotateString(str,n);
    }
    public static void LeftRotateString(String str,int n){
        char[] arr=str.toCharArray();
        for (int i = 0; i < n; i++) {
            char temp=arr[0];
            for (int j = 0; j < arr.length-1; j++) {
                arr[j]=arr[j+1];
            }
            arr[arr.length-1]=temp;
        }
        System.out.println(arr);
    }
}
